import 'package:cesi/model/Coffee.dart';
import 'package:flutter/material.dart';

class Shop extends ChangeNotifier {
  //coffee menu
  final List<Coffee> _coffeeMenu = [
    Coffee(
      name: 'americano',
      price: '21',
      imagePath: 'assets/images/coffee_01.png',
      rating: '4.2',
    ),
    Coffee(
      name: 'cappoccino',
      price: '21',
      imagePath: 'assets/images/咖啡 (2).png',
      rating: '3.5',
    ),
    Coffee(
      name: 'cipphon',
      price: '35',
      imagePath: 'assets/images/咖啡 (3).png',
      rating: '4.6',
    ),
    Coffee(
      name: 'pure tea',
      price: '14',
      imagePath: 'assets/images/咖啡 (4).png',
      rating: '2.5',
    ),
  ];

  //custom cart
  List<Coffee> _cart = [];

  //getter methods
  List<Coffee> get coffeeMenu => _coffeeMenu;
  List<Coffee> get cart => _cart;

  //add to cart
  void addToCart(Coffee coffeeItem, int quantity) {
    for (int i = 0; i < quantity; i++) {
      _cart.add(coffeeItem);
    }
    notifyListeners();
  }

  //remove to cart
  void removeFromCart(Coffee coffee) {
    _cart.remove(coffee);
    notifyListeners();
  }
}
